🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    "Can´t convert NoneType to int" issue

    UIFlow
    2
    3
    1.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RoToR
      last edited by

      Hello,

      I am working on a simple program.

      I receive a value between 0 and 1000 by MQTT and convert it to a digital value from 0 to 255.
      Then I want to put it on the DAC channel 0.

      But if I want to proceed with the digital value within the main loop I get the error "Can´t convert NoneType to int".

      0_1704356408997_8076330c-0e14-4cbd-9c91-211de1ce1a02-image.png

      I understand that this is a NoneType, which can´t convert into an integer, but I need to work with the digital value in the main loop, because I have to do some calculations (filtering), which is not possible in the MQTT function.

      How can I solve this issue?

      0_1704355631045_a5b77d31-9fea-4870-a52e-e88a63c1765a-image.png

      R 1 Reply Last reply Reply Quote 0
      • R
        RoToR @RoToR
        last edited by

        I found a workaround meanwhile with if-else.

        It is not nice, but it´s working:

        • I convert the DAC Value into a String.

        • Then I check, if it is "None", if yes I send a 0 to the DAC.

        • If DAC Value is not "None" I convert it back to integer and send it directly to the DAC.

        0_1704359879454_92383df8-f87b-449d-977a-84a9a8fc9ffc-image.png

        1 Reply Last reply Reply Quote 0
        • ajb2k3A
          ajb2k3
          last edited by

          Are you using a “convert to int” block to convert the value being sent to the dac?

          UIFlow, so easy an adult can learn it!
          If I don't know it, be patient!
          I've ether not learned it or am too drunk to remember it!
          Author of the WIP UIFlow Handbook!
          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post